document.getElementById('registrationForm').addEventListener('submit', function (event) {
    event.preventDefault();

    const userId = document.getElementById('userId').value;
    const userPassword = document.getElementById('userPassword').value;
    const userName = document.getElementById('userName').value;
    const userImage = document.getElementById('userImage').files[0]; // 从文件输入控件获取文件

    if (!userImage) {
        alert('请选择一个图片文件');
        return;
    }

    const formData = new FormData();
    formData.append('user_id', userId);
    formData.append('user_password', userPassword);
    formData.append('user_name', userName);
    formData.append('user_image', userImage);

    fetch('http://localhost:8080/userInFo', {
        method: 'GET',
        body: formData
    }).then(response => {
        if (response.ok) {
            alert('上传成功');
        } else {
            response.text().then(text => alert('上传失败: ' + text));
        }
    }).catch(error => {
        console.error('上传出错', error);
        alert('上传出错');
    });
});
